package com.ld.wms.business.notice.controller;


import com.ld.wms.business.approve.vo.req.MaterialExampleInventoryApproveReqVo;
import com.ld.wms.business.approve.vo.resp.MaterialExampleInventoryApproveRespVo;
import com.ld.wms.business.notice.service.WarnConfigService;
import com.ld.wms.business.notice.service.impl.WarnInfoServiceImpl;
import com.ld.wms.business.notice.vo.req.WarnConfigReqVo;
import com.ld.wms.business.notice.vo.resp.WarnConfigRespVo;
import com.ld.wms.business.notice.vo.resp.WarnInfoRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GenerateListVo;
import com.ld.wms.common.vo.GeneratePageListVo;
import com.ld.wms.common.vo.PrimaryKeyReqVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2025-04-23
 */
@Slf4j
@Tag(name = "预警信息口关接口")
@RestController
public class WarnConfigController {

    @Autowired
    private WarnConfigService warnConfigService;

    @Autowired
    private WarnInfoServiceImpl warnInfoService;


    @PostMapping("/api/wms/warnConfig/configWarn")
    @Operation(summary = "预警设置")
    public ResultResponse<ResultResponseEnum> receiveApprove(
            @RequestBody WarnConfigReqVo reqVo
    ) {
        warnConfigService.configWarn(reqVo);
        return ResultResponse.success();
    }


    @GetMapping("/api/wms/warnConfig/getConfigWarn")
    @Operation(summary = "获取预警配置信息")
    public ResultResponse<WarnConfigRespVo> getConfigWarn(
    ) {
        WarnConfigRespVo warnConfig = warnConfigService.getWarnConfig();
        return ResultResponse.success(warnConfig);
    }

    @GetMapping("/api/wms/warnInfo/getPageList")
    @Operation(summary = "预警信息列表")
    public ResultResponse<GeneratePageListVo<WarnInfoRespVo>> getWarnInfoList(
            @Parameter(description = "当前页数") @RequestParam(defaultValue = "1") Integer current,
            @Parameter(description = "每页展示条数") @RequestParam(defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<WarnInfoRespVo> pageList = warnInfoService.getPageList(current, size);
        return ResultResponse.success(pageList);
    }

    @GetMapping("/api/wms/warnInfo/getById")
    @Operation(summary = "预警信息详情")
    public ResultResponse<WarnInfoRespVo> getById(
           @RequestParam Long id
    ) {
        WarnInfoRespVo warnInfoRespVo = warnInfoService.getById(id);
        return ResultResponse.success(warnInfoRespVo);
    }

    @PostMapping("/api/wms/warnConfig/warnInIgnore")
    @Operation(summary = "预警信息忽略")
    public ResultResponse<ResultResponseEnum> warnInIgnore(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        warnInfoService.warnInIgnore(reqVo.getId());
        return ResultResponse.success();
    }
}

